function validate_form(thisform)
{
  if($(thisform).validationEngine("validate")){
	 return true;
  }
  return false;
}
function render(){
	var oper = $("#showErrMsg").attr("oper");
	if(oper=="0"){
		$("#showErrMsg").addClass("hide");
	}else{
		var val = $("#showErrMsg").attr("val");
		if(val=="200"){
			$("#showErrMsg").removeClass("hide");
			$("#formDiv").hide();
			$("#success").show().html($("#showErrMsg").find("div").html()).prev(".widget-body").hide();
		}else{
			$("#showErrMsg").removeClass("hide");
		}
	}
}
$(function() {
	var layero = $("#backPasswordForm");
	 $(document).find("input").each(function(){
		 $(this).attr("autocomplete","off");
	 });
	 $("#backPasswordForm").submit(function () {
		  $(this).ajaxSubmit({success: function (data) { //提交成功的回调函数  
			  		$("#showErrMsg").attr("oper",data.oper);
			  		if(data.status!=200){
			  			$("#showErrMsg").attr("oper","");
			  		}
	                $("#showErrMsg").attr("val",data.status);
	                $("#showErrMsg").find("div").html(data.desc);
	                render();
	                $("#randCodeImage").click();
			 }
		  });
		  return false;
    });
	 render();
	layero.delegate(".password","keyup change",function(e){
	   var value = $(this).val();
	   var targetname = $(this).attr("targetname");
	   var val = "";
	   val = encryptByAes(value,aesKey);
	   $(layero.find("input[name='"+targetname+"']").get(0)).val(val);
    }); 
    $("#backPasswordForm").validationEngine('attach', {promptPosition : "topRight", autoPositionUpdate : true});
});
